package com.vegetable.modules.entity.finance.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 客户回款预警记录VO
 * </p>
 *
 * @author vegetable
 * @since 2025-10-24
 */
@Data
@ApiModel(value = "CustomerCollectionAlertRecordVO", description = "客户回款预警记录VO")
public class CustomerCollectionAlertRecordVO implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty(value = "预警设置ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long alertId;

    @ApiModelProperty(value = "客户ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long customerId;

    @ApiModelProperty(value = "客户名称")
    private String customerName;

    @ApiModelProperty(value = "销售出库单ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long salesOutId;

    @ApiModelProperty(value = "销售订单ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long salesOrderId;

    @ApiModelProperty(value = "销售出库单编号")
    private String docNo;

    @ApiModelProperty(value = "订单时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private Date orderTime;

    @ApiModelProperty(value = "订单金额")
    private BigDecimal orderAmount;

    @ApiModelProperty(value = "已回款金额")
    private BigDecimal receivedAmount;

    @ApiModelProperty(value = "未回款金额")
    private BigDecimal unreceivedAmount;

    @ApiModelProperty(value = "逾期天数")
    private Integer overdueDays;

    @ApiModelProperty(value = "预警阈值（天数）")
    private Integer alertThreshold;

    @ApiModelProperty(value = "预警级别：1轻微2严重3紧急")
    private Integer alertLevel;

    @ApiModelProperty(value = "预警级别名称")
    private String alertLevelName;

    @ApiModelProperty(value = "预警状态：0未处理1已处理2已忽略3已回款")
    private Integer alertStatus;

    @ApiModelProperty(value = "预警状态名称")
    private String alertStatusName;

    @ApiModelProperty(value = "预警时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date alertTime;

    @ApiModelProperty(value = "处理时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date handleTime;

    @ApiModelProperty(value = "处理人ID")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long handleUserId;

    @ApiModelProperty(value = "处理人姓名")
    private String handleUserName;

    @ApiModelProperty(value = "处理备注")
    private String handleRemark;

    @ApiModelProperty(value = "台账标识 0寿光 1河北 2聊城 3云南")
    private Integer regionId;

    /**
     * 获取预警级别名称
     */
    public String getAlertLevelName() {
        if (alertLevel == null) {
            return "";
        }
        switch (alertLevel) {
            case 1:
                return "轻微";
            case 2:
                return "严重";
            case 3:
                return "紧急";
            default:
                return "未知";
        }
    }

    /**
     * 获取预警状态名称
     */
    public String getAlertStatusName() {
        if (alertStatus == null) {
            return "";
        }
        switch (alertStatus) {
            case 0:
                return "未处理";
            case 1:
                return "已处理";
            case 2:
                return "已忽略";
            case 3:
                return "已回款";
            default:
                return "未知";
        }
    }
}
